package com.opo5.logisticsmanagement.service.impl;

import com.opo5.logisticsmanagement.common.R;
import com.opo5.logisticsmanagement.dao.IndexPageDao;
import com.opo5.logisticsmanagement.domain.IndexCable;
import com.opo5.logisticsmanagement.service.IndexPageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class IndexPageServiceImpl implements IndexPageService {
    @Autowired
    IndexPageDao indexPageDao;
    @Override
    public R cablePlan() {
        List<IndexCable> list = indexPageDao.getIndexInfo();
        R r = new R();
        r.setCode(200);
        r.setMsg("success");
        class tmp{
            public String name;
            public String value;
            tmp(String s1, String s2){
                this.name = s1;
                this.value = s2;
            }
        }
        List<tmp> res = new ArrayList<>();
        list.forEach((i)->{
            res.add(new tmp(i.getCablename(), i.getInnum()));
            res.add(new tmp(i.getCablename(), i.getOutnum()));
        });
        r.setData(res);
        return r;
    }
}
